using System;
using System.Collections;
using System.Data;
using System.Collections.Generic;

using WHC.Pager.Entity;
using WHC.Hotel.IDAL;
using WHC.Hotel.Entity;
using WHC.OrderWater.Commons;

namespace WHC.Hotel.DAL
{
	/// <summary>
	/// Manufacture 的摘要说明。
	/// </summary>
	public class Manufacture : BaseDAL<ManufactureInfo>, IManufacture
	{
		#region 对象实例及构造函数

		public static Manufacture Instance
		{
			get
			{
				return new Manufacture();
			}
		}
		public Manufacture() : base("TB_Manufacture","ID")
		{
		}

		#endregion

		#region Helper Methods

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
        protected override ManufactureInfo DataReaderToEntity(IDataReader dr)
		{
			ManufactureInfo entity = new ManufactureInfo();
			SmartDataReader reader = new SmartDataReader(dr);

			entity.ID = reader.GetInt32("ID");
            entity.HandNo = reader.GetString("HandNo");
			entity.Name = reader.GetString("Name");
			entity.Address = reader.GetString("Address");
			entity.Telephone1 = reader.GetString("Telephone1");
			entity.Telephone2 = reader.GetString("Telephone2");
			entity.ContactUser = reader.GetString("ContactUser");
			entity.ContactMobile = reader.GetString("ContactMobile");
			entity.Email = reader.GetString("Email");
			entity.Note = reader.GetString("Note");
			entity.LastUpdated = reader.GetDateTime("LastUpdated");

			return entity;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(ManufactureInfo obj)
		{
		    ManufactureInfo info = obj as ManufactureInfo;
			Hashtable hash = new Hashtable(); 
			
			//hash.Add("ID", info.ID);
            hash.Add("HandNo", info.HandNo);
			hash.Add("Name", info.Name);
			hash.Add("Address", info.Address);
			hash.Add("Telephone1", info.Telephone1);
			hash.Add("Telephone2", info.Telephone2);
			hash.Add("ContactUser", info.ContactUser);
			hash.Add("ContactMobile", info.ContactMobile);
			hash.Add("Email", info.Email);
			hash.Add("Note", info.Note);
			hash.Add("LastUpdated", info.LastUpdated);
			
			return hash;
		}
		#endregion
	}
}